<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
           //测试对象
    let object1={};
    // console.log(object1);
    // console.log(typeof(object1));
    //创建对象
    let student={
        name: '张三',
        age: 18,
        gender: 'M',
        say: function(message){
            console.log('hi'+message);
        } ,
        doSomething: function(work){
            console.log("目前正在做"+work);
        }
    }
    //调用对象
    console.log(student.age);//访问属性通过.运算
    console.log(student['age']);//通过属性名
    student.say("你是一头猪")
    student.doSomething("我在敲代码")
    //通过构造方法进行创建对象
    function People(age,name,gender,message,something){
            this.name=name;
            this.age=age;
            this.gender=gender;
            this.msg=function(message){
                console.log('hi'+message);
            }
            this.do=function(something){
                console.log("我在"+something);
            }
    }
    //创建对象并调用函数
    let student1=new People(18,'张三','M',"你好啊","做工作");
    console.log(student1.age);
    console.log(student1.name);
    console.log(student1.gender);
    student1.msg("dd");
    let student2=new Object();
    student2.name='明明';
    student2['age']=18;
    student2['gender']='M';
    student2['say']=function(message){
        console.log("hi"+message);
    }
    //测试
    console.log(student2.age);
    console.log(student2.name);
    console.log(student2.gender);
    student2.say("终于写完了");
    </script>

</head>
<body>
 
    
</body>
</html>